<include file="Public:header" />
<div class="container clearfix">
    <include file="Public:sidebar" />
    <!--/sidebar-->
    <div class="main-wrap">
        <div class="crumb-wrap">
        </div>        
        <div class="result-wrap">           
            <form name="myform" id="myform" method="post">
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>游戏名称</th>
                            <th>区服名称</th>
                            <th>推广地址</th>
                            <th>短地址</th>
                            <th>操作</th>
                        </tr>                        
                        <?php foreach($list as $v){ ?>
                        <tr>
                            <td width='10%'><?php echo $v['gamename'] ?></td>
                            <td width='10%'><?php echo $v['areaname'] ?></td>
                            <td width='50%'><?php echo $v['url'];?></td>
                            <td width='20%'>
                                <?php if($v['url']!='' && $v['surl']==''){?>
                                <a href="javascript:void(0)" id="<?php echo $v['url']?>" onclick="shortlink(this.id,<?php echo $v['refer'];?>)">生成短链接</a>
                                <?php }else{ ?>
                                <a href="<?php echo $v['surl']?>" target="_blank"><?php echo $v['surl']?></a>
                                <?php }?>
                            </td>
                            <td width='10%'>
                                <a href="javascript:void(0)" onclick="createlink(<!--{$v['game_id']}-->,<!--{$v['area_num']}-->)">提取链接</a>
                            </td>
                        </tr>
                        <?php }?>
                    </table>
                    <div class="list-page"><!--{$page}--></div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
        function createlink(game_id,area_num){
            var param="game_id="+game_id+"&area_num="+area_num;
            $.ajax({
                type:'post',
                url:'http://www.248game.com/cps.php?s=link/createlink',
                data:param,
                dataType:'json',
                success:function(data){
                    if(data['ret']==0){
                        window.location.reload();
                    }else{
                        alert(data['msg']);
                        return;
                    }
                }
            });
        }
        function shortlink(url,id){            
            $.ajax({
                    type:'post',
                    url:'http://www.248game.com/cps.php?s=link/shortLink',
                    data:{'url':url,'id':id},
                    dataType:'json',
                    success:function(data){
                        if(data['ret']==0){
                            window.location.reload();
                        }else{
                            alert(data['msg']);
                        }
                    }
                });
        }        
</script>
<!--/main-->
</div>
</body>
</html>
